# -*- coding: utf-8 -*-
"""
 @Time    : 2021/1/28 下午3:34
 @Author  : tgy
 
"""
import os
import fnmatch


def list_file_path(base_path, exclude_paths=None, include_patterns=None):
    ...
    if not base_path:
        return

    # 判断路径是否存在
    if not os.path.exists(base_path):
        return

    for path, dirs, files in os.walk(base_path):
        ...
        if exclude_paths:
            dirs[:] = [d for d in dirs if d not in exclude_paths]

        for file in files:
            if not include_patterns:
                yield os.path.join(path, file)
            elif any(tuple(fnmatch.fnmatch(file, patter) for patter in include_patterns)):
                yield os.path.join(path, file)


def filter_file(file_paths, include_patterns):
    ...
    for file_path in file_paths:
        ...


if __name__ == '__main__':
    ...
    base_path = '/Users/apple/Documents/python/python-guide'
    exclude_paths = ('python-base',)
    include_file_patterns = ('*.py','*.pyc')
    for file_path in list_file_path(base_path,include_patterns=include_file_patterns):
        print(file_path)
